﻿@if (User.Identity.IsAuthenticated)
{
    Data.Repositories.UserRepository rep = new Data.Repositories.UserRepository();
    @Html.Partial("_MyFamilyOnline", rep.GetUserByEmail(User.Identity.Name))
}
else
{
<script type="text/javascript">

    $().ready(function () {

        $("#email").Watermark("email@endereço.com");

        $("#checkTentar").click(function () {
            if ($(this).is(':checked')) {
                $("#family_date").hide("fast");
                $("#data").hide("fast");
            } else {
                $("#family_date").show("fast");
                $("#data").show("fast");
            }
            $("#family_date").val("");
        });

    });

    function valida() {
        if (!isValidEmailAddress($("#email").val()) || $("#email").val() == "email@endereço.com" || $("#email").val() == "")
        { alert("Insira um email correcto!"); return false; }
        if (!$("#checkTentar").is(':checked') && $("#family_date").val() =="")
        {alert("Tem de indicar a data de nascimento ou previsão do parto.");return false; }
        return true;
    }

    function isValidEmailAddress(emailAddress) {
        var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
        return pattern.test(emailAddress);
    };
</script>
<div id="forYourFamilyContainer_homePageMainForYourFamily">
    <div class="secondary-module">
        <div style="float: right; margin-top: 5px;">

            @Html.ActionLink("Faça Login", "logon", "Account", null, new { @class = "lkbutton" })
        </div>
        <div style="float: left">
            <h2>Minha familia</h2>
        </div>
        <div class="clear">
            <div>
                <div>
                    <img src="../../Content/Images/family.png" style="margin-left:50px;" alt="A sua gravidez semana a semana" />
                </div>
                <p>
                    <b>Subscreva gratuitamente a nossa newsletter e receba no seu email informação indicada
                        para si.</b></p>
                <div>
                    @using (Html.BeginForm("SignNewsletter", "Tools", FormMethod.Post, new { onsubmit = "return valida();" }))
                    {
                            <div style="margin-top:10px;"> 
                            Estou a tentar engravidar <input type="checkbox" name="tentar" id="checkTentar" value="1" />
                            </div>
			        <div id="data" style="margin-bottom: 10px;margin-top:10px;">
                        <div style="margin-bottom: 10px;">Indique a data de nascimento ou previsão do parto</div>
                        <input name="family_date" id="family_date" type="text" class="input_text date" style="width: 76px;
                            float: left" />
		                </div>

                        <div class="clear">
                        </div>
                        <div>
                            <div style="margin-bottom: 10px;">
                                Endereço de email:</div>
                            <div style="float: left;">
                                <input id="email" name="email" type="text" class="input_text" />
                            </div>
                            <div style="float: right;margin-right:15px;">
                                <input type="submit" value="Enviar" id="btnPostFamily" />
                            </div>
                            <div class="clear">
                            </div>
                        </div>
                    }
                </div>
            </div>
        </div>
    </div>
</div>
}